const path = require('path');
const utils = require('./utils/index');

let filesList = [];
const routerPath = path.resolve('./app/router');
utils.readFileList(routerPath, filesList);
filesList = filesList.map((res) => {
  return res.replace(`${routerPath}`, './router');
});
module.exports = async (app) => {
  for (let index = 0; index < filesList.length; index++) {
    await require(filesList[index])(app);
  }
  app.get('/*', app.controller.app.index);
};
